﻿@using EasyXaf.LowCode.WorkflowEditors.Nodes

@if (Workflow != null)
{
    <div id="@WorkflowEditorEleId" class="workflow-editor">
        <CascadingValue Value="UndoManager" IsFixed="true">
            <div class="workflow-toolbar-container">
                <WorkflowToolbar @ref="WorkflowToolbar"
                                 @bind-PanAndZoomPanelVisible="PanAndZoomPanelVisible"
                                 Container="Workflow.CurrentContainer"
                                 ContainerChanged="ContainerChanged"
                                 Zoom="Zoom"
                                 ZoomChanged="async(zoom)=>await ZoomChangedAsync(zoom)"
                                 BestFit="BestFitAsync"
                                 FitToDrawing="FitToDrawingAsync" />
            </div>
            <div class="workflow-viewport">
                <CascadingValue Value="WorkflowMode.Design">
                    <SequenceNode CssClass="workflow-canvas" Sequence="Workflow.CurrentContainer" />
                </CascadingValue>
            </div>
            @if (PanAndZoomPanelVisible)
            {
                <div class="workflow-navigator-container">
                    <WorkflowNavigator WorkflowEditorEleId="@WorkflowEditorEleId" Container="Workflow.CurrentContainer" />
                </div>
            }
        </CascadingValue>
    </div>
}

@code {
    public static RenderFragment Create(WorkflowModel model)
    {
        return @<WorkflowRenderer Model="model" />;
    }
}